//
//  ConnectWXViewController.swift
//  ParkManage
//
//  Created by cf on 2020/9/21.
//  Copyright © 2020 diligrp. All rights reserved.
//

import UIKit

class ConnectWXViewController: UIViewController {

    @IBOutlet weak var accountTextField: UITextField!
    @IBOutlet weak var pwdTextField: UITextField!
    @IBOutlet weak var sureButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        configUITheme()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: animated)
    }
    
    func configUITheme() {
        
        title = "微信关联账号"
        
        sureButton.makeRoundedCorners(22.5)
        
        navigationItem.leftBarButtonItem =
        UIBarButtonItem(image: R.image.left_back_icon(),
                        style: .plain,
                        target: self,
                        action: #selector(backAction))
        navigationItem.leftBarButtonItem?.tintColor = .black
    }

    @IBAction func connectWX(_ sender: UIButton) {
        
    }
    
    @objc func backAction() {
        navigationController?.popViewController(animated: true)
    }
}

extension ConnectWXViewController: UITextFieldDelegate {
    
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        
        if accountTextField == textField {
            
            if range.location >= 11 {
                return false
            }
        } else if pwdTextField == textField {
            if range.location >= 6 {
                return false
            }
        }
        
        return true
    }
}
